# Contributor: Andrew Bell <andrew.bell.ia@gmail.com>
# Maintainer: Andrew Bell <andrew.bell.ia@gmail.com>
pkgname=xerces-c
pkgver=3.2.3
pkgrel=0
pkgdesc="A validating XML parser written in a portable subset of C++"
url="https://xerces.apache.org/index.html"
arch="all"
license="Apache-2.0"
makedepends="cmake curl-dev icu-dev"
subpackages="$pkgname-samples $pkgname-doc $pkgname-dev"
source="$pkgname-$pkgver.tar.gz::https://github.com/apache/xerces-c/archive/v$pkgver.tar.gz"

build() {
	local thread_support=-Dthreads:BOOL=ON
	case "$CARCH" in
		s390x) thread_support=-Dthreads:BOOL=OFF ;;
	esac
	cmake -B build \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_INSTALL_PREFIX="$pkgdir"/usr \
		$thread_support \
		-Dnetwork-accessor=curl \
		-Dmessage-loader=icu \
		-Dtranscoder=icu \
		. $CMAKE_CROSSOPTS
	make -C build
}

check() {
	cd build
	ctest
}

package() {
	make -C build install
}

samples() {
	pkgdesc="$pkgdesc (compiled samples)"

	mkdir -p $subpkgdir/usr
	mv $pkgdir/usr/bin $subpkgdir/usr
}

sha512sums="aaafe2de4ea156d94e71e3631c79bd66660badf17bf2a19587a0ca34011f70bd1584a0beef909409a3ff05eecea9d37ffee6dbb267625f59217fd86705d2cd28  xerces-c-3.2.3.tar.gz"
